BuffEffect102 = BaseBuffEffect:new();
BuffEffect102.__index = BuffEffect102;

function BuffEffect102:new()
    local object = {};
    setmetatable(object, BuffEffect102);
    return object;
end

function BuffEffect102:action(fight,buff,...)
    local result = select('3',...);
    local target = buff.target;
    local skill = select('2',...);
    local skillBean = skill.skill.skillBean;

    if skillBean.f_IfATK ~= EnumConst.SkillTypeEnum.NORMAL_ATTACK then
        return EnumConst.IBuffEffect.SUCCESS;
    end
                
    local buffvalue = decodeJsonStrToTabel(buff.buffBean.f_Value);

    --计算边界值
    local value = FighterAttributeManager.getFightAttr(target, EnumConst.FighterAttributeEnum.HP) * buffvalue[1]/ EnumConst.TEN_THOUSANDTH;
    if target.hp < value then
        local maxHp = FighterAttributeManager.getFightAttr(target, EnumConst.FighterAttributeEnum.HP);
        local att = maxHp * buffvalue[2] / EnumConst.TEN_THOUSANDTH;

        fightLog("[EFFECT]Fighter "..buff.target.fighterId.." Buff"..buff.modelId.." 触发普通攻击附加自身最大生命值额外伤害BUFF效果");
        local damage = Mathf.Floor(result.damage + att);
        fightLog("[DAMAGE]"..buff.source.fighterId.."对".. buff.target.fighterId.."计算BUFF(" ..buff.modelId.. ")对普通攻击附加自身最大生命值额外伤害BUFF效果[4]结果"..subDigitalNum(damage,4));
        result.damage = damage;
    end
    return EnumConst.IBuffEffect.SUCCESS;
end
